﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Common;
using Atom.Utility.Data;
using System.Data;
using Atom.Entity.Medicare;
using Atom.Utility;
using Atom.Entity.Medicare.Model;
using Atom.Entity.HIS;

namespace Atom.DAL.HIS
{
    public class CommonDataDAL : BaseDAL
    {

        public List<MedicarePaientEntity> GetAllPaient(DateTime dtBegin, DateTime dtEnd, string inhosid)
        {
            try
            {
                string sql = ReadSqlXML.GetSql("medicare");
                DbCommand cmd = DataAccess.GetSqlStringCommand(sql);
                DataAccess.AddInParameter(cmd, "dtBegin", DbType.String, dtBegin);
                DataAccess.AddInParameter(cmd, "dtEnd", DbType.String, dtEnd);
                DataAccess.AddInParameter(cmd, "inhosid", DbType.String, inhosid);
                return DataAccessExtensive.ExecuteListEntity<MedicarePaientEntity>(this.DataAccess, cmd);

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /*
         ,List<BAZAEntity> bazaList,List<BAF1Entity> baf1List,List<BAF2Entity> baf2List,List<BAF3Entity> baf3List,
            List<BAF4Entity> baf4List,List<BAF5Entity> baf5List,List<BAF9Entity> baf9List,List<BAFAEntity> bafaList,List<BAFBEntity> bafbList,List<BAFCEntity> bafcList,List<BAFDEntity> bafdList )
        {
         */

        public List<BAZAEntity> QueryBAZAEntityList(DateTime dtBegin, DateTime dtEnd, string inhosid)
        {


            string sql = ReadSqlXML.GetSql("baza");
            if (string.Empty.Equals(sql))
            {
                return new List<BAZAEntity>();
            }
            DbCommand cmd = DataAccess.GetSqlStringCommand(sql);
            DataAccess.AddInParameter(cmd, "dtBegin", DbType.String, dtBegin);
            DataAccess.AddInParameter(cmd, "dtEnd", DbType.String, dtEnd);
            DataAccess.AddInParameter(cmd, "inhosid", DbType.String, inhosid);


            return DataAccessExtensive.ExecuteListEntity<BAZAEntity>(this.DataAccess, cmd);
        }

        public List<BAF1Entity> QueryBAF1EntityList(DateTime dtBegin, DateTime dtEnd, string inhosid)
        {


            string sql = ReadSqlXML.GetSql("baf1");
            if (string.Empty.Equals(sql))
            {
                return new List<BAF1Entity>();
            }
            DbCommand cmd = DataAccess.GetSqlStringCommand(sql);
            DataAccess.AddInParameter(cmd, "dtBegin", DbType.String, dtBegin);
            DataAccess.AddInParameter(cmd, "dtEnd", DbType.String, dtEnd);
            DataAccess.AddInParameter(cmd, "inhosid", DbType.String, inhosid);

            return DataAccessExtensive.ExecuteListEntity<BAF1Entity>(this.DataAccess, cmd);
        }

        public List<BAF2Entity> QueryBAF2EntityList(DateTime dtBegin, DateTime dtEnd, string inhosid)
        {


            string sql = ReadSqlXML.GetSql("baf2");
            if (string.Empty.Equals(sql))
            {
                return new List<BAF2Entity>();
            }
            DbCommand cmd = DataAccess.GetSqlStringCommand(sql);
            DataAccess.AddInParameter(cmd, "dtBegin", DbType.String, dtBegin);
            DataAccess.AddInParameter(cmd, "dtEnd", DbType.String, dtEnd);
            DataAccess.AddInParameter(cmd, "inhosid", DbType.String, inhosid);

            return DataAccessExtensive.ExecuteListEntity<BAF2Entity>(this.DataAccess, cmd);
        }

        public List<BAF3Entity> QueryBAF3EntityList(DateTime dtBegin, DateTime dtEnd, string inhosid)
        {


            string sql = ReadSqlXML.GetSql("baf3");
            if (string.Empty.Equals(sql))
            {
                return new List<BAF3Entity>();
            }
            DbCommand cmd = DataAccess.GetSqlStringCommand(sql);
            DataAccess.AddInParameter(cmd, "dtBegin", DbType.String, dtBegin);
            DataAccess.AddInParameter(cmd, "dtEnd", DbType.String, dtEnd);
            DataAccess.AddInParameter(cmd, "inhosid", DbType.String, inhosid);

            return DataAccessExtensive.ExecuteListEntity<BAF3Entity>(this.DataAccess, cmd);
        }

        public List<BAF4Entity> QueryBAF4EntityList(DateTime dtBegin, DateTime dtEnd, string inhosid)
        {


            string sql = ReadSqlXML.GetSql("baf4");
            if (string.Empty.Equals(sql))
            {
                return new List<BAF4Entity>();
            }
            DbCommand cmd = DataAccess.GetSqlStringCommand(sql);
            DataAccess.AddInParameter(cmd, "dtBegin", DbType.String, dtBegin);
            DataAccess.AddInParameter(cmd, "dtEnd", DbType.String, dtEnd);
            DataAccess.AddInParameter(cmd, "inhosid", DbType.String, inhosid);

            return DataAccessExtensive.ExecuteListEntity<BAF4Entity>(this.DataAccess, cmd);
        }

        public List<BAF5Entity> QueryBAF5EntityList(DateTime dtBegin, DateTime dtEnd, string inhosid)
        {


            string sql = ReadSqlXML.GetSql("baf5");
            if (string.Empty.Equals(sql))
            {
                return new List<BAF5Entity>();
            }
            DbCommand cmd = DataAccess.GetSqlStringCommand(sql);
            DataAccess.AddInParameter(cmd, "dtBegin", DbType.String, dtBegin);
            DataAccess.AddInParameter(cmd, "dtEnd", DbType.String, dtEnd);
            DataAccess.AddInParameter(cmd, "inhosid", DbType.String, inhosid);

            return DataAccessExtensive.ExecuteListEntity<BAF5Entity>(this.DataAccess, cmd);
        }

        public List<BAF9Entity> QueryBAF9EntityList(DateTime dtBegin, DateTime dtEnd, string inhosid)
        {


            string sql = ReadSqlXML.GetSql("baf9");
            if (string.Empty.Equals(sql))
            {
                return new List<BAF9Entity>();
            }
            DbCommand cmd = DataAccess.GetSqlStringCommand(sql);
            DataAccess.AddInParameter(cmd, "dtBegin", DbType.String, dtBegin);
            DataAccess.AddInParameter(cmd, "dtEnd", DbType.String, dtEnd);
            DataAccess.AddInParameter(cmd, "inhosid", DbType.String, inhosid);

            return DataAccessExtensive.ExecuteListEntity<BAF9Entity>(this.DataAccess, cmd);
        }


        public List<BAFAEntity> QueryBAFAEntityList(DateTime dtBegin, DateTime dtEnd, string inhosid)
        {


            string sql = ReadSqlXML.GetSql("bafa");
            if (string.Empty.Equals(sql))
            {
                return new List<BAFAEntity>();
            }
            DbCommand cmd = DataAccess.GetSqlStringCommand(sql);
            DataAccess.AddInParameter(cmd, "dtBegin", DbType.String, dtBegin);
            DataAccess.AddInParameter(cmd, "dtEnd", DbType.String, dtEnd);
            DataAccess.AddInParameter(cmd, "inhosid", DbType.String, inhosid);

            return DataAccessExtensive.ExecuteListEntity<BAFAEntity>(this.DataAccess, cmd);
        }

        public List<BAFBEntity> QueryBAFBEntityList(DateTime dtBegin, DateTime dtEnd, string inhosid)
        {


            string sql = ReadSqlXML.GetSql("bafb");
            if (string.Empty.Equals(sql))
            {
                return new List<BAFBEntity>();
            }
            DbCommand cmd = DataAccess.GetSqlStringCommand(sql);
            DataAccess.AddInParameter(cmd, "dtBegin", DbType.String, dtBegin);
            DataAccess.AddInParameter(cmd, "dtEnd", DbType.String, dtEnd);
            DataAccess.AddInParameter(cmd, "inhosid", DbType.String, inhosid);

            return DataAccessExtensive.ExecuteListEntity<BAFBEntity>(this.DataAccess, cmd);
        }

        public List<BAFCEntity> QueryBAFCEntityList(DateTime dtBegin, DateTime dtEnd, string inhosid)
        {


            string sql = ReadSqlXML.GetSql("bafc");
            if (string.Empty.Equals(sql))
            {
                return new List<BAFCEntity>();
            }
            DbCommand cmd = DataAccess.GetSqlStringCommand(sql);
            DataAccess.AddInParameter(cmd, "dtBegin", DbType.String, dtBegin);
            DataAccess.AddInParameter(cmd, "dtEnd", DbType.String, dtEnd);
            DataAccess.AddInParameter(cmd, "inhosid", DbType.String, inhosid);

            return DataAccessExtensive.ExecuteListEntity<BAFCEntity>(this.DataAccess, cmd);
        }

        public List<BAFDEntity> QueryBAFDEntityList(DateTime dtBegin, DateTime dtEnd, string inhosid)
        {


            string sql = ReadSqlXML.GetSql("bafd");
            if (string.Empty.Equals(sql))
            {
                return new List<BAFDEntity>();
            }
            DbCommand cmd = DataAccess.GetSqlStringCommand(sql);
            DataAccess.AddInParameter(cmd, "dtBegin", DbType.String, dtBegin);
            DataAccess.AddInParameter(cmd, "dtEnd", DbType.String, dtEnd);
            DataAccess.AddInParameter(cmd, "inhosid", DbType.String, inhosid);

            return DataAccessExtensive.ExecuteListEntity<BAFDEntity>(this.DataAccess, cmd);
        }



        /*----------------------------------------2011.06.08----------------------------------------------------------------*/


        /// <summary>
        /// 查询N04表数据
        /// </summary>
        /// <param name="dtBegin"></param>
        /// <param name="dtEnd"></param>
        /// <param name="inhosid"></param>
        /// <returns></returns>

        public List<N04Entity> QueryN04EntityList(DateTime dtBegin, DateTime dtEnd, string inhosid)
        {


            string sql = ReadSqlXML.GetSql("tcbasb");
            if (string.Empty.Equals(sql))
            {
                return new List<N04Entity>();
            }
            DbCommand cmd = DataAccess.GetSqlStringCommand(sql);
            DataAccess.AddInParameter(cmd, "dtBegin", DbType.String, dtBegin);
            DataAccess.AddInParameter(cmd, "dtEnd", DbType.String, dtEnd);
            DataAccess.AddInParameter(cmd, "inhosid", DbType.String, inhosid);

            return DataAccessExtensive.ExecuteListEntity<N04Entity>(this.DataAccess, cmd);
        }



    }
}
